<template>
  <ul class="goods">
    <li v-for="item in goodsList" :key="item.id">
      <div class="goods-top">
        <img :src="item.imgUrl" alt="" />
        <div class="top">
          <img :src="item.leftUrl" alt="" class="zb" />
          <img :src="item.rightUrl" alt="" class="bf" />
        </div>
        <div class="bottom">
          <img :src="item.imgUrl" alt="" class="yuan" />
          <span class="actorname">{{ item.actorname }}</span>
          <span class="actortag">{{ item.actortag }}</span>
        </div>
      </div>
      <div class="goods-bottom">
        <div class="goods-bottom-top">{{ item.name }}</div>
        <div class="goods-bottom-bottom">
          <div class="price">￥{{ item.price }}</div>
          <img :src="item.byUrl" alt="" />
          <div class="sales">销量{{ item.sales }}</div>
        </div>
      </div>
    </li>
  </ul>
</template>

<script setup>
import { getGoodsListApi } from "@/utils/api/api.js";
import { ref, onMounted } from "vue";
const goodsList = ref([]);
onMounted(() => {
  fetchData();
});
//获取接口数据
const fetchData = async () => {
  await getGoodsListApi().then(({ data }) => {
    goodsList.value = data.data;
  });
};
</script>

<style scoped lang="less">
.goods {
  margin-top: 274px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  // padding: 5px 10px;
  height: 100%;
  li {
    margin: 10px 0;
    width: calc(50% - 0.25rem);
    height: 100%;
    border-radius: 5px;
    .goods-top {
      height: 280px;
      img {
        width: 100%;
        height: 280px;
      }
      .top {
        position: relative;
        display: flex;
        justify-content: space-between;
        // bottom: 330px;
        img {
          position: absolute;
          text-align: center;
          bottom: 290px;
        }
        .zb {
          // padding-left: 20px;
          width: 50px;
          height: 45px;
          bottom: 245px;
        }
        .bf {
          padding-left: 140px;
          bottom: 260px;
          width: 30px;
          height: 30px;
        }
      }
      .bottom {
        display: flex;
        align-items: center;
        position: relative;
        bottom: 55px;
        .yuan {
          width: 30px;
          height: 30px;
          border-radius: 50%;
        }
        span {
          font-size: 16px;
          font-weight: 700;
          color: #fff;
          padding: 0 8px;
        }
        .actortag {
          background-color: rgba(24, 23, 23, 0.3);
          border-radius: 5px;
        }
      }
    }
    .goods-bottom {
      background-color: #fff;
      .goods-bottom-top {
        font-size: 17px;
        text-align: left;
      }
      .goods-bottom-bottom {
        display: flex;
        align-items: center;
        .price {
          font-size: 26px;
          color: #e05050;
        }
        img {
          margin: 0 10px;
          width: 30px;
          height: 20px;
        }
        .sales {
          color: red;
          font-size: 16px;
          padding: 2px 4px;
          background-color: rgba(228, 94, 94, 0.849);
          border-radius: 5px;
        }
      }
    }
  }
}
</style>
